[20250218] BOJ / G4 / 키 순서 / 김수연 #141
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[20250218] BOJ / G4 / 키 순서 / 김수연
🧷 문제 링크
https://www.acmicpc.net/problem/2458
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
두 학생의 키를 비교한 결과를 통해 자신의 키가 몇번째인지 알 수 있는 학생들의 수 구하기
🔍 풀이 방법
graph를 통해서 학생들을 돌면서 자신보다 (키가 작은 학생수 + 키가 큰 학생수) == (총학생수-1) 인 학생들은 키 순서가
확정이므로 정답갯수를 하나 올려주었다.
⏳ 회고
지금 코드는 모든 학생에 대해서 mincnt와 maxcnt를 새로 구해주는데
dfs를 이용해서 그래프에서 가장 끝인 애는 mincnt=0부터 1씩 증가하면서 현재 학생까지 저장해주면 이미 지나쳐온 학생들은 굳이 새로 안구하고 저장되어 있는 값을 불러옴으로써 시간이 단축될 거 같다고 생각했는데 거기까지는 구현을 못했어여
(시간복잡도가 안좋네여....ㅜ)